package com.excellent.search.pojo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author Xxacker
 * @Document 用于创建索引库
 *      指定数据库的名称为 "goods", 表名为为 "docs" , 1个分片，0个副本
 */
@Data
@Document(indexName = "goods", type = "docs", shards = 1, replicas = 0)
public class Goods {
    @ApiModelProperty("spuId")
    @Id
    private Long id;

    @ApiModelProperty("所有需要被搜索的信息，包含标题，分类，甚至品牌")
    @Field(type=FieldType.Text, analyzer="ik_max_word")
    private String all;

    @ApiModelProperty("卖点")
    @Field(type=FieldType.Keyword, index=false)
    private String subTitle;

    @ApiModelProperty("品牌id")
    private Long brandId;

    @ApiModelProperty("1级分类id")
    private Long cid1;

    @ApiModelProperty("2级分类id")
    private Long cid2;

    @ApiModelProperty("3级分类id")
    private Long cid3;

    @ApiModelProperty("创建时间")
    private Date createTime;

    @ApiModelProperty("价格")
    private List<Long> price;

    @ApiModelProperty("List<sku> 信息的 json 结构")
    @Field(type = FieldType.Keyword, index = false)
    private String skus;

    @ApiModelProperty("可搜索的规格参数，key是参数名，值是参数值")
    private Map<String, Object> specs;
}
